<?php
/**
 * Created by PhpStorm.
 * User: shuai
 * Date: 2016/7/27
 * Time: 20:59
 * 新手教程
 */
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_app_class('admin', 'admin', 0);
pc_base::load_app_class('foreground');
pc_base::load_sys_class('format', '', 0);
pc_base::load_sys_class('form', '', 0);
class pay_manage extends admin {

    public function __construct() {
        $this->shuafen_recharge_conf = pc_base::load_model('shuafen_recharge_conf_model');
        $this->shuafen_recharge_record = pc_base::load_model('shuafen_recharge_record_model');
        parent::__construct();
    }


    public function pay_money_conf(){
        $page = max(intval($_GET['page']), 1);
        $infos = $this->shuafen_recharge_conf->listinfo(array('is_show'=>'Y'), '', $page);
        $pages = $this->shuafen_recharge_conf->pages;
        include $this->admin_tpl('pay_money_conf/pay_money_list');
    }

    public function add_pay_money_conf(){
        if (isset($_POST['dosubmit'])) {
            $info = $_POST['info'];
            if($_POST['id']){
                $info['update_time'] = SYS_TIME;
                $id = $this->shuafen_recharge_conf->update($info, array('id'=>$_POST['id']));
                showmessage(L('修改成功'), 'index.php?m=shuafen&c=pay_manage&a=pay_money_conf');
            }else{
                $info['create_time'] = SYS_TIME;
                $id = $this->shuafen_recharge_conf->insert($info, true);
                if ($id) {
                    showmessage(L('添加成功'), 'index.php?m=shuafen&c=pay_manage&a=pay_money_conf');
                }else {
                    showmessage(L('operation_failure'), 'index.php?m=shuafen&c=pay_manage&a=pay_money_conf');
                }
            }
        }else{
            $action = $_GET['action'];
            if($action){
                $id = $_GET['id'];
                $money = $this->shuafen_recharge_conf->get_one(array('id'=>$id));
            }
        }
        include $this->admin_tpl('pay_money_conf/add_pay_conf');
    }

    public function delete_pay_conf(){
        $id = $_GET['id'];
        if($id){
            $this->shuafen_recharge_conf->update(array('is_show'=>'N'),array('id'=>$id));
            showmessage(L('删除成功'), 'index.php?m=shuafen&c=pay_manage&a=pay_money_conf');
        }
    }

    public function pay_record(){
        $page = max(intval($_GET['page']), 1);
        $infos = $this->shuafen_recharge_record->listinfo('','time desc , id desc ', $page);
        $pages = $this->shuafen_recharge_record->pages;
        include $this->admin_tpl('member/pay_record');
    }
}
